import React, { memo, useState,useEffect } from 'react'

const App = memo(() => {
  const [counter, setCounter] = useState(100)

  function changTitle () {
    setCounter(counter + 1)
  }
  /**
   * 1.参数一 回调函数，在渲染完成后立即调用
   * 2.参数二 数组，当数组中的值发生变化时，才会重新调用回调函数
   */
  useEffect(() => {
    console.log('componentDidMount')
    document.title = counter
  }, [counter])
  return (
    <div>
      <h1>App： counter-{counter}</h1>
      <button onClick={() => changTitle()}>+1</button>
    </div>
  )
})

export default App